package book;

import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:图书
 * User: lenovo
 * Date: 2024-06-04
 * Time: 20:13
 */
public class Book {
    private String name;//书名
    private String auther;//作者
    private int price;//价格
    private String type;//书的类型
    private boolean isBorrowed;//书是否被借出

    public Book(String name, String auther, int price, String type) {
        this.name = name;
        this.auther = auther;
        this.price = price;
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuther() {
        return auther;
    }

    public void setAuther(String auther) {
        this.auther = auther;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isBorrowed() {
        return isBorrowed;
    }

    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }

    @Override
    public String toString() {
        return "Book{" +
                "书名：'" + name + '\'' +
                ", 作者：'" + auther + '\'' +
                ", 价格：" + price +
                ", 类型：'" + type + '\'' +
                ((isBorrowed == true)?",借出情况：已借出":",借出情况：未借出")  +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Book book = (Book) o;
        return price == book.price && isBorrowed == book.isBorrowed && Objects.equals(name, book.name) && Objects.equals(auther, book.auther) && Objects.equals(type, book.type);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, auther, price, type, isBorrowed);
    }
}
